package cn.boat.router.consumer;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class PartitionData implements Comparable<PartitionData>{
    private int partitionNumber;
    private int partitionLeader;
    private String leaderIp;
    private int leaderPort;
    private List<Integer> isr;
    public PartitionData() {
        partitionLeader =0;
        partitionNumber =0;
        isr = new ArrayList<>();
        leaderIp ="";
        leaderPort =0;
    }

    public String getLeaderIp() {
        return leaderIp;
    }

    public void setLeaderIp(String leaderIp) {
        this.leaderIp = leaderIp;
    }

    public int getLeaderPort() {
        return leaderPort;
    }

    public void setLeaderPort(int leaderPort) {
        this.leaderPort = leaderPort;
    }

    public List<Integer> getIsr() {
        return isr;
    }

    public void setIsr(List<Integer> isr) {
        this.isr = isr;
    }

    public PartitionData(int partitionNumber, int partitionLeader, List<Integer> isr) {
        this.partitionNumber = partitionNumber;
        this.partitionLeader = partitionLeader;
        this.isr = isr;
    }

    public int getPartitionNumber() {
        return partitionNumber;
    }

    public void setPartitionNumber(int partitionNumber) {
        this.partitionNumber = partitionNumber;
    }

    public int getPartitionLeader() {
        return partitionLeader;
    }

    public void setPartitionLeader(int partitionLeader) {
        this.partitionLeader = partitionLeader;
    }

    @Override
    public String toString() {
        return "PartitionData{" +
                "partitionNumber=" + partitionNumber +
                ", partitionLeader=" + partitionLeader +
                ", leaderIp='" + leaderIp + '\'' +
                ", leaderPort='" + leaderPort + '\'' +
                ", isr=" + isr +
                '}';
    }

    @Override
    public int compareTo(PartitionData o) {
        int s = this.partitionNumber-o.partitionNumber;
        return s;
    }
}
